package com.beerandjesus.webapp.sportofkings.handicapper.struts.action;

import com.beerandjesus.sportofkings.handicapper.model.brisnet.singlefile.CardVOImpl;
import org.springframework.stereotype.Component;

/**
 * Tear down and rebuild the jockey rating databases
 * Date: Jun 1, 2012
 * Time: 1:57:03 PM
 */
@Component
public class RebuildDatabaseAction extends DatabaseAction {

    private int rowCount;

    public String execute() throws Exception {
        getDatabase().rebuildJockeyRatingDatabase();
        CardVOImpl vo = new CardVOImpl();
        vo.setFilePath(getFileUpload().getAbsolutePath());
        getBuilder().addAllJockeys(vo);
        getFileUpload().delete();
        int count = getDatabase().getJockeyPerformanceDatabaseRowCount();
        setRowCount(count);
        return SUCCESS;
    }

    public int getRowCount() {
        return rowCount;
    }

    public void setRowCount(int rowCount) {
        this.rowCount = rowCount;
    }
}
